object ConstructorDemo01 {
def main(arg: Array[String]): Unit={
  //Val person = new PersonA("tom",99)//不会走主构造器
  val person =new PersonA("tom")
  println(person)
  val al = new A
  val a2 = new A()
}
}

/**
 * 构造器的快速入门
 * 穿件Person对象的同时初始化对象的age属性值和name属性值
 */
class PersonA(inName: String,inAge: Int){
  var name: String =inName
  var age: Int = inAge
  age +=10
  println("age="+age)
  def this(name:String){
    //辅助构造器，必须在第一行显式调用主构造器（可以使直接，也可以是间接）
    this("jack",10)
    println("---------------")
    //this
    this.name = name//重新赋值
  }
  //重写了toString,便于输出对象的信息
  override  def toString: String={
    "name=" + this.name + "\t age" + this.age
  }
}
class A(){

}
